<template>
  <div class="frs_box" style="width:500px">
    <div class="top_content">
      <div class="tit">功能用房统计</div>
    </div>
    <div class="frs_process_cnt">
        <div class="frs_process_num_tit">当前人数</div>
         <el-row :gutter="20" v-for="item in progressList" :key="item.id" class="frs_process_row">
            <el-col style="width:80px" class="frs_process_name">{{item.name}}</el-col>
            <el-col style="width:calc(100% - 200px)" class="frs_process_box_len frs_process_box">
                <div class="process_bg" 
                :class="e <= item.point ? 'process_bg_yes' : 'process_bg_no'"
                :style="{left: e*9 + 'px'}"
                :key="item.id + '_process_bg_' + e "
                v-for="e in listLength" >
                </div>
            </el-col>
            <el-col style="width:60px" class="frs_process_num">{{item.completeNum}}/{{item.planNum}}</el-col>
            <el-col style="width:60px" class="frs_process_num">{{item.completeNum}}</el-col>
        </el-row>
    </div>
  </div>
</template>
<script>
// import API from "@/commons/api.js";
export default {
  props: {
    // commonDefaultParams: {
    //   type: Object,
    //   default: {}
    // }
  },
  data() {
    return {
      // 流程数据
       progressList: [
        {
            planNum: 2,   // 计划数量
            completeNum: 1,  // 完成数量
            id:1,
            name:"特讯室"
        },
        {
            planNum: 17,
            completeNum: 7,
            id:2,
            name:"询问室"
        },
        {
            planNum: 19,
            completeNum: 11,
            id:3,
            name:"讯问室"
        },
        {
            planNum: 249,
            completeNum: 58,
            id:4,
            name:"侯问室"
        }
      ],
      listLength:20,
    };
  },
  methods: {
      calculate(row){
          if(row.planNum == 0){
              return 0
          }else{
             return parseInt(((row.completeNum/row.planNum)*this.listLength).toFixed(0));
          }
      },
      changeDate(){
          this.progressList.map(e =>{
              e.point = this.calculate(e)
          })
      },
       windowChange() {
            let width = document.querySelector('.frs_box .frs_process_box_len').offsetWidth;
            // console.log(width);
            if(parseInt((width/9 - 5).toFixed(0)) < 2){
                this.listLength = 2
            }else{
                this.listLength = parseInt((width/9 - 5).toFixed(0))
            }
            this.changeDate()
        },
  },
  computed: {},
  created() {
      this.changeDate()
  },
  mounted() {
       this.$nextTick(() => {
        window.addEventListener('resize', this.windowChange);
        this.windowChange()
    });
  },
   beforeDestroy() {
        window.removeEventListener('resize', this.windowChange); // 通过有名函数 解除监听窗口事件
    }
};
</script>
<style lang="scss" scoped>
* {
  box-sizing: border-box;
}
.frs_box {
  position: relative;
  width: 100%;
  height: 100%;
  padding: 0 5px !important;
  border: 1px solid #07515c;
  background: #12243a;
  box-shadow: 0px 0px 10px 0px rgba(7, 81, 92, 1) inset;
//   background-image: url(../../assets/img/sign.png);
  background-repeat: no-repeat;
  background-position: 50% 12px;
  background-size: 42%;
  .top_content {
    line-height: 22px;
    text-align: left;
    font-size: 16px;
    color: #00ffff;
    padding: 10px;
  }
  .frs_process_cnt{
    height: calc(100% - 42px);
    .frs_process_num_tit{
        color: #ffffff;
        font-size: 12px;
        text-align: right;
        line-height: 20px;
        padding-right: 20px;
    }
    .frs_process_row{
        margin-bottom: 10px;
        .frs_process_name{
            color: #ffffff;
            text-align: right;
            font-size: 14px;
            line-height: 34px;
        }
        .frs_process_num{
            color: #DABC16;
            text-align: center;
            line-height: 34px;
        }
        .frs_process_box{
            position: relative;
            height: 34px;
            width: 100%;
            .process_bg{
                width: 32px;
                height: 34px;
                position: absolute;
                top: 0;
            }
            .process_bg_yes{
                background: url("~@/assets/img/box_light.png") no-repeat;
                background-size: 100% 100%;
            }
            .process_bg_no{
                background: url("~@/assets/img/box_dark.png") no-repeat;
                background-size: 100% 100%;
            }
        }
    }
  }
}
.skinTwo{
    .frs_box{
        box-shadow: 0px 0px 10px 0px #027ec5 inset;
        border: 1px solid #027ec5;
        background: rgba(14,23,43,.5);
        // background-image: url(../../assets/img/sign_skinTwo.png);
        background-repeat: no-repeat;
        background-position: 50% 12px;
        background-size: 20%;
         .top_content {
            color: #41baff;
        }
        .frs_process_cnt{
           .frs_process_row{
               .frs_process_box{
                   .process_bg_yes{
                        background: url("~@/assets/img/box_light.png") no-repeat;
                        background-size: 100% 100%;
                    }
                    .process_bg_no{
                        background: url("~@/assets/img/box_dark.png") no-repeat;
                        background-size: 100% 100%;
                    }
               }
           } 
        }
    }
}
</style>
<style>
</style>